package xyz.riceball.context;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import xyz.riceball.annotation.ComponentScan;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 暂时不实现
 * </p>
 *
 * @author xiaovcloud
 * @since 2021/6/29 21:43
 */
@Deprecated
public class AnnotationConfigApplicationContext extends AbstractApplicationContext {

    private final Logger log = LoggerFactory.getLogger(getClass());


    public <T> AnnotationConfigApplicationContext(Class<T> clazz) {
        super(doScan(clazz));
    }

    //TODO
    private static String[] doScan(Class<?> clazz) {
        //ComponentScan放在第一位
        ComponentScan componentScanAnnotation = clazz.getAnnotation(ComponentScan.class);
        if (componentScanAnnotation != null) {
            String[] basePackages = componentScanAnnotation.basePackages();
            Class<?>[] basePackageClasses = componentScanAnnotation.basePackageClasses();
            //noinspection MismatchedQueryAndUpdateOfCollection
            List<String> componentScanBeanNames = new ArrayList<>(Arrays.asList(basePackages));
            for (Class<?> cla : basePackageClasses) {
                String typeName = cla.getTypeName();
                componentScanBeanNames.add(typeName);
            }

        }
        return null;
    }


}
